import Vue from "vue";
import VueRouter from "vue-router";
import Layouts from "../layouts"; //动态生成左侧菜单


Vue.use(VueRouter);

const routes = [
    {
        path: "/",
        redirect: "/home",
        component: Layouts,
        children: [
            {
                path: 'home',
                meta: { title: '首页', icon: "el-icon-s-home" },
                component: () => import("../views/Home.vue"),
            },
            {
                path: 'system',
                meta: { title: '系统管理', icon: "el-icon-s-home" },
                component: Layouts,
                children: [
                    {
                        path: "item1",
                        meta: { title: "用户管理", icon: "el-icon-s-home" },
                        component: () => import("../views/system/item1"),
                    },
                    {
                        path: "item2",
                        meta: { title: "产品管理", icon: "el-icon-s-home" },
                        component: () => import("../views/system/item2"),
                    },
                ]
            }
        ]

    },

];
const router = new VueRouter({
    mode: "history",
    base: process.env.BASE_URL,
    routes,
});
router.beforeEach((to, from, next) => {
    document.title = to.name;
    next();
})

export default router;